<template>
	<view>
		<!--  #ifdef  H5 -->
		<!-- <view class="inv-h-w" style="top: 11vw;">
			<view :class="['inv-h',Inv==0?'inv-h-se':'']" @click="myTeam(0,1)">图片</view>
			<view :class="['inv-h',Inv==1?'inv-h-se':'']" @click="myTeam(1,1)">视频</view>
		</view> -->
		<!--  #endif -->
		<!--  #ifdef  APP-PLUS -->
		<!-- <view class="inv-h-w">
			<view :class="['inv-h',Inv==0?'inv-h-se':'']" @click="myTeam(0,1)">图片</view>
			<view :class="['inv-h',Inv==1?'inv-h-se':'']" @click="myTeam(1,1)">视频</view>
		</view> -->
		<!--  #endif -->
		<view class="main">

			<view class="shuru">
				<text class="shuru_tit t1">店铺名称</text>
				<input type="text" class="shuru_text t1" value="" v-model="dpname" placeholder="请输入店铺名称" />
			</view>
			<!-- <view class="shuru">
				<text class="shuru_tit t1">店铺地址</text>
				<input type="text" class="shuru_text t1" value="" v-model="adtit" placeholder="请输入店铺地址" />
			</view> -->

			<view class="shuru">
				<text class="shuru_tit t1" style="width:40%;display: block;float: left;height: auto;">店铺所属地区</text>
				<picker mode="multiSelector" @columnchange="bindMultiPickerColumnChange1" :value="dmultiIndex"
					:range="dmultiArray" style="text-align: right;width: 60%;display: block;float: right;">
					<view class="uni-input shuru_text2 t1" v-if="diqu!=''"
						style="width: 100%;display: block;float: left;height: auto;margin-right: 0;">
						{{diqu}}
					</view>
					<view class="uni-input shuru_text2 t1" v-if="diqu==''"
						style="display: block;float: right;width: 100%;height: auto;margin-right: 0;">
						{{dmultiArray[0][dmultiIndex[0]]}}，{{dmultiArray[1][dmultiIndex[1]]}}，{{dmultiArray[2][dmultiIndex[2]]}}，{{dmultiArray[3][dmultiIndex[3]]}}
					</view>

				</picker>
			</view>
			<!-- <view class="shuru">
				<text class="shuru_tit t1">店铺所在小区</text>
				<picker @change="dbindPickerChange" :value="communitys" :range="darray" class="shuru_text2 t1"
					style="text-align: right;" range-key="name" v-if="communitys!=''">
					{{darray[dindex].name}}
				</picker>
				<input type="text" class="shuru_text t1" value="" v-model="community" placeholder="请输入所在小区"
					style="height: 10vw;" v-if="communitys==''" />
			</view> -->

			<view class="shuru">
				<text class="shuru_tit t1">店铺精确位置</text>
				<view class="shuru_text t1" @click="dingwei"
					style="position: relative;height: auto;line-height: 6vw;padding: 2vw 0;padding-right: 4vw;">
					{{address}}
					<image src="/static/img/turn.png" mode="heightFix"
						style="height: 4vw; margin-top: 3vw;position: absolute;right: 0;top: 0;background: #fff;">
					</image>
				</view>
			</view>
			<view class="shuru">
				<text class="shuru_tit t1">店铺详细地址</text>
				<input type="text" class="shuru_text t1" value="" v-model="mdxxdz" placeholder="xx大厦x层xxxx室" />
			</view>
			<view class="shuru">
				<text class="shuru_tit t1">产品名称</text>
				<input type="text" class="shuru_text t1" value="" v-model="protit" placeholder="请输入产品名称" />
			</view>
			<view class="shuru">
				<text class="shuru_tit t1">产品原价</text>
				<input type="digit" class="shuru_text t1" value="" v-model="proopri" placeholder="请输入产品原价" />
			</view>
			<view class="shuru">
				<text class="shuru_tit t1">产品现价</text>
				<input type="digit" class="shuru_text t1" value="" :focus="fwf()" v-model="pronpri" placeholder="请输入产品现价" />
			</view>
			<view class="shuru">
				<text class="shuru_tit t1">产品总量</text>
				<input type="number" class="shuru_text t1" value="" v-model="pronum" placeholder="请输入剩余产品数量" />
			</view>
				<view class="shuru">
				<text class="shuru_tit t1">产品服务费</text>
				<text class="shuru_text t1">{{fuwufei/100}}元</text>
				
			</view>
			<view class="baodan_zhu t1">
				<view class="baodan_tit1 t1">广告产品介绍图片</view>
				<view class="baodan_tit1 t7">注：最多可添加5张图片</view>
				<view class="uni-padding-wrap uni-common-mt baodan_into1" @click="chooseImage1">
				</view>
				<view class="imgi" v-for="(item,index) in proimg" :key="'p'+index">
					<image src="/static/img/clo.png" class="imgdel" @click="delimg(index)"></image>
					<!-- <view class="imgi" v-for="(item,index) in proimg" :key="'p'+index"> -->
					<!-- {{item}} -->
					<image :src="item" mode="aspectFill"></image>
				</view>
			</view>
			<view class="tuic t2" @click="zhuanru()" style="margin-bottom: 30vw;">{{buts}}</view>
		</view>
	</view>
</template>

<script>
	// let mapSearch = weex.requireModule('mapSearch');
	export default {
		data() {
			return {
				mainid: '',
				address: '',
				dnui1: [],
				dnui2: [],
				dnui3: [],
				dnui4: [],
				dmultiArray: [
					[],
					[],
					[],
					[],
				],
				mdxxdz: '',
				darray: [{
					'name': '',
					'id': ''
				}],
				dmultiIndex: [0, 0, 0, 0],
				dpickerid1: '',
				dpickerid2: '',
				dpickerid3: '',
				dpickerid4: '',
				longitude: '',
				latitude: '',
				adrname: '',
				longitude1: '',
				latitude1: '',
				adrname1: '',
				proimg: [],
				proimg1: [],
				proimgid: [],
				pronpri: '',
				proopri: '',
				protit: '',
				adpri: '',
				adint: '',
				adtit: '',
				dpname: '',
				address1: '',
				longitude11: '',
				latitude11: '',
				adrname11: '',
				longitude21: '',
				latitude21: '',
				adrname21: '',
				pronpri1: '',
				proopri1: '',
				protit1: '',
				adpri1: '',
				adint1: '',
				adtit1: '',
				dpname1: '',
				id: '',
				sellPicIdStr: '',
				checks: true,
				dindex: 0,
				community: '',
				communitys: '',
				pronum: '',
				proynum: '',
				adrid: '',
				proimgid1: [],
				diqu: '',
				pid: '',
				cid: '',
				qid: '',
				xid: '',
				aid: '',
				aname: '',
				adrid: '',
				community: '',
				dpid: '',
				provinceId: '',
				cityId: '',
				districtId: '',
				areaId: '',
				mdxxdz1: '',
				buts: '上传并支付',
				fuwufei:'',
			}
		},
		onLoad(options) {
			console.log(options);
			var _this = this;
			_this.id = options.id;
			_this.amount = options.amount;
			_this.dadr();
			uni.getStorage({
				key: 'user',
				success: function(res) {
					_this.mainid = res.data.id;
				}
			});
			if (options.id) {
				setTimeout(function() {
					_this.xq();
				}, 1500);
			}
		},
		onShow() {
			// this.handleAuthorize()
		},
		methods: {


			fwf() {
				var _this = this;
				uni.request({
					header: {
						'Content-Type': 'application/json', //自定义请求头信息
					},
					url: getApp().globalData.url + 'ad/getAdSellServiceAmount', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						amount: _this.pronpri*100
					},
					success: (res) => {
						console.log(res.data)
						if (res.data.status == '200') {
							_this.fuwufei=res.data.data.serviceAmount;
						}
					},
					fail: (error) => {
						console.log(error)
					}
				});
			},

			dbindPickerChange: function(e) {
				// console.log(e);
				this.dindex = e.detail.value
				console.log(this.dindex);
				this.community = this.darray[this.dindex].name;
				this.communitys = this.darray[this.dindex].name;
				if (this.dindex == this.darray.length - 1) {
					this.communitys = '';
					this.community = '';
					console.log(this.communitys);
					console.log(this.community);
				}
			},
			bindMultiPickerColumnChange1: function(e) {
				var _this = this;
				// _this.diqu = '';
				_this.dmultiIndex[e.detail.column] = e.detail.value;
				_this.diqu = '';
				if (e.detail.column == 0) {
					_this.dpickerid1 = _this.dnui1[e.detail.value].id;
					_this.dpickerid2 = '';
					_this.dpickerid3 = '';
					_this.dpickerid4 = '';
					// _this.provinceId = _this.dnui1[e.detail.value].id;
					_this.dmultiIndex = [e.detail.value, 0, 0, 0];
					_this.dadr1();
				} else if (e.detail.column == 1) {
					_this.dpickerid2 = _this.dnui2[e.detail.value].id;
					_this.dpickerid3 = '';
					_this.dpickerid4 = '';
					// _this.cityId = _this.dnui2[e.detail.value].id;
					_this.dmultiIndex[2] = 0;
					_this.dmultiIndex[3] = 0;
					// _this.bizAddressCode = _this.dnui2[e.detail.value].id;
					// console.log(_this.bizAddressCode)
					_this.dadr2();
				} else if (e.detail.column == 2) {
					_this.dpickerid3 = _this.dnui3[e.detail.value].id;
					// _this.districtId = _this.dnui3[e.detail.value].id;
					_this.dpickerid4 = '';
					_this.dmultiIndex[3] = 0;
					_this.dadr3();
				} else if (e.detail.column == 3) {
					_this.dmultiIndex[3] = e.detail.value;
					// console.log(e.detail.value);
					console.log(_this.dmultiIndex[3]);
					_this.dpickerid4 = _this.dnui4[e.detail.value].id;
					// _this.areaId = _this.dnui4[e.detail.value].id;
					// _this.communitys = '1';
					console.log(e.detail.column);
					console.log(_this.communitys);
					// _this.dmultiIndex[3] = 0;
					_this.darray = [{
						'name': '',
						'id': ''
					}];
					_this.xiaoqu();
				}
				this.$forceUpdate()
			},

			dadr() {
				var _this = this;
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'area/areaList/', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						parentId: ''
					},
					success: (res) => {
						if (res.data.status == '200') {
							_this.dnui1 = res.data.data;
							for (var i = 0; i < res.data.data.length; i++) {
								_this.dmultiArray[0].push(res.data.data[i].name);
							}
							_this.dpickerid1 = res.data.data[0].id;
							// _this.pid = res.data.data[0].id;
							_this.dadr1();
						}
					},
					fail: (error) => {
						console.log(error)
					}
				});
			},
			dadr1() {
				var _this = this;
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'area/areaList/' + _this.dpickerid1, //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						parentId: _this.dpickerid1 //	用户ID（mainId）
					},
					success: (res) => {
						if (res.data.status == '200') {
							_this.dnui2 = res.data.data;
							var list = [];
							for (var i = 0; i < res.data.data.length; i++) {
								list.push(res.data.data[i].name);
							}
							this.dmultiArray.splice(1, 1, list)
							// console.log(_this.dpickerid2);
							if (!_this.dpickerid2) {
								_this.dpickerid2 = res.data.data[0].id;
							} else {
								for (var i = 0; i < _this.dnui2.length; i++) {
									if (_this.dpickerid2 == _this.dnui2[i].id) {
										// console.log(_this.dnui2[i].id);console.log(i);
										_this.dmultiIndex[1] = i;
									}
								}
							}
							_this.dadr2();
						}
					},
					fail: (error) => {
						console.log(error)
					}
				});
			},
			dadr2() {
				var _this = this;
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'area/areaList/' + _this.dpickerid2, //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						parentId: _this.dpickerid2 //	用户ID（mainId）
					},
					success: (res) => {
						if (res.data.status == '200') {
							if (res.data.data) {
								_this.dnui3 = res.data.data;
								var list = [];
								for (var i = 0; i < res.data.data.length; i++) {
									list.push(res.data.data[i].name);
								}
								this.dmultiArray.splice(2, 1, list)
								if (!_this.dpickerid3) {
									_this.dpickerid3 = res.data.data[0].id;
								} else {
									for (var i = 0; i < _this.dnui3.length; i++) {
										if (_this.dpickerid3 == _this.dnui3[i].id) {
											// console.log(_this.dnui2[i].id);console.log(i);
											_this.dmultiIndex[2] = i;
										}
									}
								}
								_this.dadr3();
								// console.log(_this.bizAddressCode);
							}
						}
					},
					fail: (error) => {
						console.log(error)
					}
				});
			},
			dadr3() {
				var _this = this;
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'area/areaList/' + _this.dpickerid3, //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						parentId: _this.qid //	用户ID（mainId）
					},
					success: (res) => {
						if (res.data.status == '200') {
							// console.log(res.data.data);
							if (res.data.data) {
								_this.dnui4 = res.data.data;
								var list = [];
								for (var i = 0; i < res.data.data.length; i++) {
									list.push(res.data.data[i].name);
								}
								_this.dmultiArray.splice(3, 1, list)
								if (!_this.dpickerid4) {
									_this.dpickerid4 = res.data.data[0].id;
								} else {
									for (var i = 0; i < _this.dnui4.length; i++) {
										if (_this.dpickerid4 == _this.dnui4[i].id) {
											// console.log(_this.dnui2[i].id);console.log(i);
											_this.dmultiIndex[3] = i;
										}
									}
								}
							}
						}
					},
					fail: (error) => {
						console.log(error)
					}
				});
			},
			xiaoqu() {
				var _this = this;
				// console.log(_this.dpickerid4);
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'area/communityList/' + _this.dpickerid4, //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						streetId: _this.dpickerid4
					},
					success: (res) => {
						// console.log(res.data.data);
						_this.darray = [];
						if (res.data.status == '200') {
							if (res.data.data.length > 0) {

								var list = [];
								for (var i = 0; i < res.data.data.length; i++) {
									list.push(res.data.data[i]);
								}
								var allno = {
									name: '以上都不在范围内',
									id: '00'
								};
								list.push(allno);
								// _this.aname=res.data.data[0].name;
								_this.darray = list;
								if (_this.communitys) {
									for (let i = 0; i < list.length; i++) {
										if (_this.communitys == list[i].name) {
											this.dindex = i
										}
									}

								} else {
									_this.communitys = '';
									_this.community = res.data.data[0].name;
									this.dindex = 0
								}
								this.$forceUpdate()
							} else {
								_this.communitys = '';
							}
						}
					},
					fail: (error) => {
						console.log(error)
					}
				});
			},
			delimg(e) {
				var list = [];
				var list1 = [];
				for (var i = 0; i < this.proimgid.length; i++) {
					if (i != e) {
						list.push(this.proimgid[i]);
						list1.push(this.proimg[i]);
					}
				}
				this.proimgid = list;
				this.proimg = list1;
			},
			// 选择是否加其他链接

			// 用户授权

			async requestAndroidPermission(permisionID) {
				var result = await permision.requestAndroidPermission(permisionID)
				var strStatus
				if (result == 1) {
					strStatus = "已获得授权"
				} else if (result == 0) {
					strStatus = "未获得授权"
					uni.showModal({
						content: '您已拒绝获取定位权限，请到设置中去打开此权限',
						showCancel: false
					});
				} else {
					uni.showModal({
						content: '您已拒绝获取定位权限，请到设置中去打开此权限',
						showCancel: false
					});
					// strStatus = "被永久拒绝权限"
				}
				// uni.showModal({
				// 	content: permisionID + strStatus,
				// 	showCancel: false
				// });
			},
			dingwei() {
				var that = this;
				that.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION');
				uni.chooseLocation({
					success: function(res) {
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
						// that.mdxxdz = res.address;
						that.address = res.address;
						that.latitude = res.latitude;
						that.longitude = res.longitude;
					}
				});
			},

			chooseImage1: function() {
				var _this = this;
				uni.chooseImage({
					count: 5,
					sizeType: ['compressed'],
					sourceType: ['album'],
					success: function(res) {
						var len = res.tempFilePaths.length;
						console.log(res.tempFilePaths);
						for (var i = 0; i < 5; i++) {
							// _this.proimg = res.tempFilePaths[0];
							var tempFilePaths = res.tempFilePaths;

							var uploadTask = uni.uploadFile({
								url: getApp().globalData.url + 'file/upload',
								filePath: tempFilePaths[i],
								name: 'file',
								formData: {},
								success: function(uploadFileRes) {
									var datamain = JSON.parse(uploadFileRes.data);
									console.log(datamain);
									if (datamain.status == 200) {
										var url = datamain.data.domain + datamain.data
											.localPath;
										_this.proimg.push(url);
										_this.proimgid.push(datamain.data.id);
										console.log(_this.proimgid)
									} else {
										uni.showToast({
											title: datamain.msg,
											icon: 'none',
											duration: 1000
										})
									}
								}
							});


							uploadTask.onProgressUpdate(function(res) {});
						}


					},
					error: function(e) {
						console.log(e);
						uni.showToast({
							title: '上传失败',
							icon: 'none',
							duration: 1000
						})
					}
				});

			},
			haddress(longitude, latitude) {
				var that = this;
				var point = new plus.maps.Point(longitude, latitude);
				plus.maps.Map.reverseGeocode(point, {},
					function(res) {
						console.log(res);
						that.adrname = res.name; //店铺位置
					},
					function(e) {});
			},
			// tup(id, v) {
			// 	var _this = this;
			// 	uni.request({
			// 		header: {
			// 			'Content-Type': 'application/json', //自定义请求头信息
			// 		},
			// 		url: getApp().globalData.url + 'file/getFile', //仅为示例，并非真实接口地址。
			// 		method: 'POST',
			// 		data: {
			// 			id: id
			// 		},
			// 		success: (res) => {
			// 			console.log(res);
			// 			uni.hideLoading(); //关闭加载动画
			// 			if (res.data.status == '200') {
			// 				var img = res.data.data.domain + res.data.data.localPath; //产品图片
			// 				_this.proimg.push(img); //广告图片		
			// 				// console.log(_this.proimg);
			// 			}
			// 		},
			// 		fail: (error) => {
			// 			// this.checks = true
			// 			console.log(error)
			// 		}
			// 	});
			// },
			xq() {
				var _this = this;
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'ad/getAdSell/' + _this.id, //仅为示例，并非真实接口地址。
					method: 'GET',
					data: {
						id: _this.id

					},
					success: (res) => {
						console.log(res);
						uni.hideLoading(); //关闭加载动画
						if (res.data.status == '200') {
							if (res.data.data) {

								_this.buts = '修改';
								var pics = [];
								if (res.data.data.pics) {
									for (let i = 0; i < res.data.data.pics.length; i++) {
										let pic = res.data.data.pics[i].domain + res.data.data.pics[i]
											.localPath;
										pics.push(pic);
										_this.proimgid1.push(res.data.data.pics[i].id);
										_this.proimgid.push(res.data.data.pics[i].id);
									}
									_this.proimg = pics;
								}
								_this.dpname1 = res.data.data.mchName;
								_this.proopri1 = res.data.data.oriAmount / 100;
								_this.protit1 = res.data.data.name;
								_this.pronpri1 = res.data.data.amount / 100;
								_this.pronum1 = res.data.data.pastNum; //总量

								_this.dpname = res.data.data.mchName;
								_this.proopri = res.data.data.oriAmount / 100;
								_this.protit = res.data.data.name;
								_this.pronpri = res.data.data.amount / 100;
								_this.pronum = res.data.data.pastNum;
								_this.adrid = res.data.data.addressVO.id;
								_this.latitude = res.data.data.addressVO.lat;
								_this.longitude = res.data.data.addressVO.lon;
								_this.latitude1 = res.data.data.addressVO.lat;
								_this.longitude1 = res.data.data.addressVO.lon;
								_this.address = res.data.data.addressVO.address;
								_this.address1 = res.data.data.addressVO.address;
								// console.log(res.data.data.addressVO.name);
								_this.mdxxdz = res.data.data.addressVO.name;
								_this.mdxxdz1 = res.data.data.addressVO.name;
								// console.log(res.data.data.addressVO.province.id);
								_this.dpickerid1 = res.data.data.addressVO.province.id;
								_this.dpickerid2 = res.data.data.addressVO.city.id;
								_this.dpickerid3 = res.data.data.addressVO.area.id;
								// console.log(res.data.data.addressVO.street.id);
								_this.dpickerid4 = res.data.data.addressVO.street.id;
								// console.log(_this.dnui1);
								for (var i = 0; i < _this.dnui1.length; i++) {
									if (_this.dnui1[i].id == _this.dpickerid1) {
										// console.log(_this.dnui1[i].id);
										_this.dmultiIndex[0] = i;
										// console.log(_this.dmultiIndex);
									}
								}
								this.$forceUpdate();
								_this.dadr1();
							}
						}
					},
					fail: (error) => {
						// this.checks = true
						console.log(error)
					}
				});
			},
			zhuanru() {
				var _this = this;
				if (_this.checks === false) {
					return false
				}
				if (_this.buts == '修改') {
					// console.log(_this.dpname1,_this.protit1,_this.proopri1,_this.pronpri1,_this.pronum1,_this.proynum1,_this.proimgid1)
					// console.log(_this.dpname,_this.protit,_this.proopri,_this.pronpri,_this.pronum,_this.proynum,_this.proimgid)
					// console.log(_this.longitude,_this.longitude1,_this.latitude,_this.latitude1,_this.mdxxdz,_this.mdxxdz1,_this.provinceId,_this.pid,_this.cityId,_this.cid,_this.districtId,_this.qid,_this.areaId,_this.xid,_this.community)
					if (_this.dpname == _this.dpname1 & _this.protit == _this.protit1 & _this.proopri == _this.proopri1 &
						_this.pronpri == _this.pronpri1 & _this.pronum == _this.pronum1 &
						_this.proimgid == _this.proimgid1 & _this.longitude == _this
						.longitude1 & _this.latitude == _this.latitude1) {
						uni.showToast({
							title: '暂无任何修改',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					// return;
				}
				if (!_this.dpname) {
					uni.showToast({
						title: '请输入店铺名称',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				// if (!_this.mdxxdz) {
				// 	uni.showToast({
				// 		title: '请输入店铺详细地址',
				// 		icon: 'none',
				// 		duration: 2000
				// 	});
				// 	return false
				// }
				if (!_this.latitude) {
					uni.showToast({
						title: '请选择店铺精确位置',
						icon: 'none',
						duration: 2000
					});
					return false
				}

				if (!_this.protit) {
					uni.showToast({
						title: '请输入产品名称',
						icon: 'none',
						duration: 2000
					});
					return false
				}

				if (!_this.proopri) {
					uni.showToast({
						title: '请输入产品原价',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				if (_this.proopri <= 0) {
					uni.showToast({
						title: '产品原价必须大于0',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				if (!_this.pronpri) {
					uni.showToast({
						title: '请输入产品现价',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				if (_this.pronpri <= 0) {
					uni.showToast({
						title: '产品现价必须大于0',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				if (_this.pronpri > 200) {
					uni.showToast({
						title: '产品现价不能大于200元',
						icon: 'none',
						duration: 2000
					});
					return false
				}

				var str = /^\+?[1-9][0-9]*$/;
				if (!_this.pronum) {
					uni.showToast({
						title: '请输入剩余产品数量',
						icon: 'none',
						duration: 2000
					});
					return false
				} else if (!(str.test(_this.pronum))) {
					uni.showToast({
						title: '红包返利利率必须为正整数',
						icon: 'none',
						duration: 2000
					});
					return false
				}

				// else{
				// 	if (_this.pronum.indexOf(".") != -1 || _this.pronum <= 0) {
				// 		uni.showToast({
				// 			title: '产品总量必须为正整数',
				// 			icon: 'none',
				// 			duration: 2000
				// 		});
				// 		return false
				// 	}
				// }

				if (_this.proimg.length <= 0) {
					uni.showToast({
						title: '请上传产品介绍图片',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				_this.checks = false;
				_this.adrchange();
			},
			adrchange() {
				var _this = this;
				console.log(_this.dpickerid1, _this.dpickerid2, _this.dpickerid3, _this.dpickerid4);
				uni.request({
					header: {
						'Content-Type': 'application/json', //自定义请求头信息
					},
					url: getApp().globalData.url + 'area/saveOrUpdateLatLon', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						address: _this.address, ////	详细地址		false	string
						areaId: _this.dpickerid3, //	区		false	string
						cityId: _this.dpickerid2, //	市		false	string
						id: _this.adrid, //	id		false	string
						lat: _this.latitude, //'36.461843', //	纬度		false	string
						lon: _this.longitude, //'116.043516',//	经度		false	string
						name: _this.mdxxdz, //	小区名		false	string
						provinceId: _this.dpickerid1, //	省		false	string
						streetId: _this.dpickerid4, //
					},
					success: (res) => {
						console.log(res);
						// uni.hideLoading(); //关闭加载动画
						_this.checks = true
						if (res.data.status == '200') {
							_this.uppro(res.data.data);
						} else if (res.data.status == '501') {
							let str = "";
							for (var a in res.data.data) str += res.data.data[a] + ";\n";
							uni.showToast({
								title: str,
								icon: 'none',
								duration: 3000
							});
						}
					},
					fail: (error) => {
						uni.hideLoading();
						this.checks = true
						console.log(error)
					}
				});
			},
			uppro(addressId) {
				var _this = this;
				var sellPicIdStr = '';
				for (var i = 0; i < _this.proimgid.length; i++) {
					if (sellPicIdStr == '') {
						sellPicIdStr = _this.proimgid[i];
					} else {
						sellPicIdStr = sellPicIdStr + ',' + _this.proimgid[i];
					}
				}
				console.log(addressId, _this.pronpri, _this.id, _this.pronum, _this.dpname, _this.protit, _this.proopri,
					_this.proynum, sellPicIdStr);
				var data = {
					addressId: addressId, //店铺地址		false							string
					amount: _this.pronpri * 100, //	产品现价		false							integer
					id: _this.id, //	id		false							string
					lastNum: _this.pronum, //	剩余产品数量		false							integer
					mchName: _this.dpname, //	店铺名称		false							string
					name: _this.protit, //	产品名称		false							string
					oriAmount: _this.proopri * 100, //	产品原价		false							integer
					pastNum: _this.pronum, //	已销售产品数量		false							integer
					picIds: sellPicIdStr, //	图片组		false							string
				};
				data = JSON.stringify(data);
				uni.showLoading();
				uni.request({
					header: {
						'Content-Type': 'application/json', //自定义请求头信息
					},
					url: getApp().globalData.url + 'ad/saveOrUpdateAdSell', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: data,
					success: (res) => {
						console.log(res);
						uni.hideLoading(); //关闭加载动画
						_this.checks = true
						if (res.data.status == '200') {
							if (_this.buts == '上传并支付') {
								uni.navigateTo({
									url: "/pages/ad/ad_goumai?id=" + _this.id + '&amount=' + _this.amount+'&isnew=' +1 +'&sell=1'
								});
								// uni.showToast({
								// 	title: '上传成功，等待审核通过。',
								// 	icon: 'none',
								// 	duration: 2000
								// });
							} else {
								uni.showToast({
									title: '修改成功',
									icon: 'none',
									duration: 2000
								});
							setTimeout(function() {

								uni.navigateBack({
									delta: 1
								})
							}, 2000)
							}
						} else if (res.data.status == '501') {
							console.log(res.data.status);
							let str = "";
							for (var a in res.data.data) str += res.data.data[a] + ";\n";
							console.log(str);
							uni.showToast({
								title: str,
								icon: 'none',
								duration: 3000
							});
						}
					},
					fail: (error) => {
						uni.hideLoading();
						this.checks = true
						console.log(error)
						let str = "";
						for (var a in error.data.data) str += res.data.data[a] + ";\n";
						uni.showToast({
							title: str,
							icon: 'none',
							duration: 3000
						});
					}
				});
			}
		}
	}
</script>

<style>
	.inv-h-w {
		background-color: #FFFFFF;
		height: 10vw;
		display: flex;
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 999;
	}

	.inv-h {
		font-size: 0.8rem;
		flex: 1;
		text-align: center;
		color: #333;
		height: 10vw;
		line-height: 10vw;
	}

	.inv-h-se {
		color: #F1C75E;
		border-bottom: 1vw solid #F1C75E;
	}

	.login_main_li_yzm {
		width: auto;
		height: 8vw;
		display: block;
		float: right;
		background: #fcbe16;
		padding: 0 3vw;
		line-height: 8vw;
		border-radius: 4vw;
	}

	.shuru {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		border-radius: 1vw;
		overflow: hidden;
		padding: 2vw 4vw;
		background: #fff;
		margin-top: 4vw;
		box-shadow: 0px 0px 5px #F2F2F2;
	}

	.shuru_tit {
		width: 45%;
		height: 10vw;
		line-height: 10vw;
		display: block;
		float: left;
	}

	.shuru_text {
		width: 55%;
		height: 10vw;
		line-height: 10vw;
		display: block;
		float: right;
		text-align: right;
	}

	select.shuru_text {
		border: none;
	}

	.shuru_text2 {
		background: url(../../static/img/turn.png) no-repeat right center;
		background-size: 2.5vw;
		line-height: 6vw;
		text-align: right;
		padding: 2vw 0;
		padding-right: 4vw;
	}

	.baodan_zhu {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		margin: 2vw 0;
		background: #fff;
		border-radius: 1vw;
		padding: 4vw;
		box-shadow: 0px 0px 5px #F2F2F2;
		margin-top: 4vw;
	}

	.baodan_tit {
		width: 100%;
		height: 8vw;
		line-height: 8vw;
		display: block;
		float: left;
		text-align: center;
	}

	.baodan_tit1 {
		width: 100%;
		height: 8vw;
		line-height: 8vw;
		display: block;
		float: left;
	}

	.baodan_into {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		line-height: 7vw;
		display: block;
		float: left;
		min-height: 40vw;
		background: url(../../static/img/jiaa.png) no-repeat center;
	}

	.baodan_into1 {
		width: 30%;
		height: 24vw;
		display: block;
		float: left;
		line-height: 7vw;
		display: block;
		float: left;
		background: url(../../static/img/jiaa.png) no-repeat center;
		border: 1px solid #eee;
		border-radius: 1vw;
		margin: 2vw 1.6%;
	}

	.imgi {
		width: 30%;
		height: 24vw;
		display: block;
		float: left;
		border: 1px solid #eee;
		margin: 2vw 1.6%;
		border-radius: 2vw;
		overflow: hidden;
		position: relative;
		text-align: center;
	}

	.imgi image {

		width: 100%;
		height: 100%;
		display: block;
		float: left;
	}

	.baodan_into_image {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		margin: 0;
	}

	.bai {
		width: 100%;
		height: 12vw;
		display: block;
		float: left;
	}

	.imgi image.imgdel {
		width: 6vw;
		height: 6vw;
		display: block;
		position: absolute;
		top: 0;
		right: 0;
		padding: 1vw;
		background: url(../../static/img/bg.png) repeat;
		z-index: 9;
		float: right;
		border-radius: 0 0 0 2vw;
	}
</style>
